package com.mundus.engine.assets.vertex;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;

import com.mundus.engine.assets.vertex.Vertex.VertexType;

public class VertexDrawable {
	
	private int _vao;
	private int _ibo;
	private Vertex _v;
	
	public int getVertexArrayObject(){ return _vao;}
	public int getIndexBufferObject(){ return _ibo;}
	public VertexType getVertexType(){ return _v.getVertexType();}
	
	public VertexDrawable(int vao, int ibo, Vertex vertex){
		_vao = vao;
		_ibo = ibo;
		_v = vertex;
	}
	
	public void draw(){
		GL30.glBindVertexArray(_vao);
		
		_v.setActiveAttributes();
		
		GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, _ibo);		
		GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_BYTE, 0);
	}
	
	public void destroy(){
		GL30.glBindVertexArray(0);
		GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
	}
}
